473,465 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

check box clear select boxes

hi,

i want to know how to clear select boxes if i unselect a check box.

sample of form code

<input type="checkbox" name="truk" value="5">

<select name="day">
<option value=""></option>
<option value="1">1</option>
<option value="2">2</option>
</select>

<select name="month">
<option value=""></option>
<option value="1">1</option>
<option value="2">2</option>
</select>

<select name="year">
<option value=""></option>
<option value="2006">2006</option>
<option value="2007">2007</option>
</select>
best regards

Jun 11 '06 #1
3 4676
yakuza said the following on 6/11/2006 1:39 PM:
hi,

i want to know how to clear select boxes if i unselect a check box.


You set the selectedIndex of the select to 0.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 11 '06 #2
yakuza wrote:

Hi,
i want to know how to clear select boxes if i unselect a check box. <input type="checkbox" name="truk" value="5">


Here, add the following attribute (the "this" keyword referring to the
checkbox object) :

onclick="foo(this)"

.... and then define your function.

<script type="text/javascript">
function foo(cbx){
var sel = ["day", "month", "year"], el=cbx.form.elements;
if(cbx.checked)
for(var ii=0; ii<sel.length; ii++)
el[sel[ii]].options[0].selected=true;
}
</script>
If you are to work with HTML forms, then I suggest you spend some time
and read the following article, which should give you a good insight
into manipulating forms.

<URL:http://www.jibbering.com/faq/faq_notes/form_access.html#faHead>

HTH
Jun 11 '06 #3

thanks, guys

Jun 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers...
2
by: Stephen Miller | last post by:
I have a page with many, dynamically generated combo boxes and I want to check all of them, before I add a unique value to specific combo. What would be the best way to work through the document...
2
by: B Blue | last post by:
How can you clear a column of check boxes? In this particular data base I have a field called "code" and it's the way to choose which records to print. How can I then clear them in one fell swoop?
2
by: aaj | last post by:
Hi all I have a continuous bound form and on each record is a tick box. The user ticks the boxes and these boxes define the batch. for future operations before they leave the page I count...
2
by: Travis.Box | last post by:
I have an MS Access userform with 16 Check Boxes. Each of the checkboxes has a different option value, which coincides with the Check Box name (eg. cb01.OptionValue = 1). At the bottom of the...
1
by: Michelle A. | last post by:
I have a 4 page form. First page has a series of check boxes of different "opportunities" to select from. These check boxes are optional but they have to at least select one (or fill in the...
1
by: Jim in Arizona | last post by:
I'm having dificulty figuring out how to process multiple check boxes on a web form. Let's say I have three check boxes: cbox1 cbox2 cbox3 The only way I can think of to code the...
10
by: Jim in Arizona | last post by:
I'm having dificulty figuring out how to process multiple check boxes on a web form. Let's say I have three check boxes: cbox1 cbox2 cbox3 The only way I can think of to code the...
1
by: Java Kumar | last post by:
Hi Friends, I have a form which contains elements such as check boxes,text box,text area ., Problem is in Check boxes. By default, Check boxes are unchecked and text boxes...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.